package com.ijustyce.market;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

import android.os.Bundle;


import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.ijustyce.market.R;


public class MainActivity extends FragmentActivity {



    public Button tv_findWork;
    private TextView tv_findTalents;
    private androidx.fragment.app.Fragment contentFragment;
    private FragmentManager fragmentManager;
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        tv_findWork = (Button) findViewById(R.id.today_tab);
        tv_findWork.setOnClickListener(itemClick);
        tv_findTalents = (TextView) findViewById(R.id.my_tab);
        tv_findTalents.setOnClickListener(itemClick);



        fragmentManager = getSupportFragmentManager();
    }

    /**
     * 点击选项
     */
    public View.OnClickListener itemClick = new View.OnClickListener() {

        @Override
        public void onClick(View v) {


            TextView textview = (TextView) v;

            FragmentTransaction transaction = fragmentManager.beginTransaction();
            switch (v.getId()) {

                case R.id.today_tab:
                    contentFragment = new My_Fragment();
                    transaction.replace(R.id.fragment_container, contentFragment);
                    break;

                case R.id.my_tab:
                    contentFragment = new Index_Fragment();
                    transaction.replace(R.id.fragment_container, contentFragment);
                    break;

                    default:
                    break;
            }
            transaction.commit();
        }
    };
}
